<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <jsp:include page="../common/header.jsp"/>
    <jsp:include page="../../common/mydate.jsp"></jsp:include>
    <jsp:include page="../../common/validform.jsp"></jsp:include>
    <jsp:include page="../../common/layer.jsp"></jsp:include>
    <jsp:include page="../../common/webupload.jsp"></jsp:include>
    <jsp:include page="../../common/ueditor.jsp"></jsp:include>

</head>
<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="${pathUrl}/admin/goods/index">产品管理</a></li>
        <li><a href="#">新增</a></li>
    </ul>
</div>
<form action="${pathUrl}/admin/goods/saveOrUpdate" class="vfrom" enctype="multipart/form-data" method="post"  enctype="application/x-www-form-urlencoded">
<input type="hidden" name="id" value="${goods.id }">
<input type="hidden" name="is_add" value="${is_add }">
<div class="session-main">
    <div class="formbody">
        <ul class="forminfo">
            <li><label>商品名称<b>*</b></label><input id="goodsName" value="${goods.goodsName }"  datatype="*" nullmsg="请输入商品名称！" name="goodsName" type="text" class="dfinput"><i class="Validform_checktip">请输入产品名称</i></li>
            <li><label>商品图片<b>*</b></label><input name="goodsImg" id="goodsImg" type="hidden" value="${goods.goodsImg }"  datatype="*" nullmsg="请选择图像！">
                <span style="display: inline-block;" id="goodsImgDiv" >选择文件</span>
               <span style="display: inline-block;" id="tupian">
            	  <c:if test="${!empty goods.goodsImg }">
                      <a href="${pathUrl}${goods.goodsImg}" target='_black'><img alt="" src="${pathUrl}${goods.goodsImg}" style="width:30px;height:30px;"></a>
                  </c:if>
            	</span>
            </span>
            </li>
            <li>


                <i id="imgTxt" class="Validform_checktip">请上传图片</i>
            </li>
            <li><label>产品货号<b>*</b></label><input value="${goods.goodsSn }" datatype="*" nullmsg="请输入产品货号！" id="goodsSn" name="goodsSn" type="text" class="dfinput"><i class="Validform_checktip">请输入产品货号</i></li>
            <li><label>市场价格<b>*</b></label><input  value="${goods.marketPrice }" datatype="*" nullmsg="请输入市场价格！" id="marketPrice" name="marketPrice" type="text" class="dfinput" ><i class="Validform_checktip">请输入市场价格</i></li>
            <li><label>销售价格<b>*</b></label><input value="${goods.sellPrice }" id="sellPrice" datatype="*" nullmsg="请输入销售价格！" name="sellPrice" type="text" class="dfinput"><i class="Validform_checktip">请输入销售价格</i></li>
            <li><label>库存<b>*</b></label><input id="goodsNumber" value="${goods.goodsNumber }" datatype="*" nullmsg="请输入库存！" name="goodsNumber" type="text" class="dfinput"><i class="Validform_checktip">请输入库存数量</i></li>
            <li><label>分类<b>*</b></label>
	            <select name="catalogId" class="select2" datatype="*" nullmsg="请选择产品分类！">
	            	<c:forEach var="vo" items="${goodsCatalogs }">
	            	     <c:choose>
	            	       <c:when test="${goods.catalogId eq vo.id}">
	            	      	 <option value="${vo.id }" selected>${vo.name }</option>
	            	       </c:when>
	            	       <c:otherwise>
	            	        <option value="${vo.id }" >${vo.name }</option>
	            	       </c:otherwise>
	            	     </c:choose>
	            	</c:forEach>
	             </select>
            </li>
            <li><label>预览数量<b>*</b></label><input id="clickCount" datatype="*" nullmsg="请输入预览数量！" value="${goods.clickCount }" name="clickCount" type="text" class="dfinput"><i class="Validform_checktip">请输入预览数量</i></li>
            <li><label>是否上架<b>*</b></label>
              <c:choose>
                 <c:when test="${goods.isOnSale eq 1 }">
                    <cite><input name="isOnSale" type="radio" value="1" checked="checked">是&nbsp;&nbsp;&nbsp;&nbsp;<input name="isOnSale" type="radio" value="0">否</cite>
                 </c:when>
                 <c:otherwise>
                   	<cite><input name="isOnSale" type="radio" value="1" >是&nbsp;&nbsp;&nbsp;&nbsp;<input checked="checked" name="isOnSale" type="radio" value="0">否</cite>
                 </c:otherwise>
               </c:choose>
            </li>
            <li><label>是否新品<b>*</b></label>
                 <c:choose>
                 <c:when test="${goods.isNew eq 1 }">
                    <cite><input name="isNew" type="radio" value="1" checked="checked">是&nbsp;&nbsp;&nbsp;&nbsp;<input name="isNew" type="radio" value="0">否</cite>
                 </c:when>
                 <c:otherwise>
                   		<cite><input name="isNew" type="radio" value="1" >是&nbsp;&nbsp;&nbsp;&nbsp;<input checked="checked" name="isNew" type="radio" value="0">否</cite>
                 </c:otherwise>
               </c:choose>
              </li>
            <li><label>是否热销<b>*</b></label>
          	 <c:choose>
                 <c:when test="${goods.isHot eq 1 }">
                 <cite><input name="isHot" type="radio" value="1" checked="checked">是&nbsp;&nbsp;&nbsp;&nbsp;<input name="isHot" type="radio" value="0">否</cite>
                 </c:when>
                 <c:otherwise>
                   		 <cite><input name="isHot" type="radio" value="1" >是&nbsp;&nbsp;&nbsp;&nbsp;<input checked="checked" name="isHot" type="radio" value="0">否</cite>
                 </c:otherwise>
               </c:choose>
            </li>
            <li>
            <label>产品详情<b>*</b></label>
            </li>
            <li><textarea name="description" id="description" style="width:95%;" cols="" rows="" >${goods.description }</textarea></li>
            <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存">
               <input type="button" class="btn" onclick="javascript:window.location.href='${pathUrl}/admin/goods/index'" value="返回" style=" background: #57e980;">
            </li>
        </ul>
    </div>
</div>
</form>
    <script type="text/javascript">
   $(function(){
        //
       $(".vfrom").Validform();

	    var ue = UE.getEditor('description');


       createWebUploader("#goodsImgDiv",function(result){
           ydlMsg("上传成功");
           $("#imgTxt").html("上传成功");
           $("#goodsImg").val(result.data.url);
           $("#tupian").empty();
           $("#tupian").html("<a href='${pathUrl}"+result.data.url+"' target='_black'><img src='${pathUrl}"+result.data.url+"' style='width: 40px;height:40px;'/></a>");
       });
   });
 </script>
</body>
</html>